package test.crawler;

import static org.junit.Assert.*;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.apache.log4j.Logger;
import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;
import org.junit.Test;

import com.crawler.Crawler;
import com.crawler.HttpClientHelper;
import com.sw.entity.Log;

public class ClientTEST {
	Logger logger=Logger.getLogger(this.getClass());
	//阿里云法庭
	@Test
	public void yuncourtTest() {
		String url="https://www.yuncourt.com/portal/main/domain/index.htm?partnerCode=OJTYQah2NiM69VqX26ZKmQ";
		Crawler c=new Crawler(url);
		if(c.loadPage())
			logger.info(c.getDoc().toString());
		
	}
	//仲裁
	@Test
	public void arbTest() {
		String url="http://118.178.168.146:58101/notice/notice?disputesId=329";
		Connection connection = Jsoup.connect(url).userAgent("Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36");
		Document doc;
		try {
			doc = connection.get();
			logger.info(doc);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			logger.error(e.getMessage());
			e.printStackTrace();
		}
		
	}
	//评估
	@Test
	public void epanTest() {
		String url="http://www.epan123.com/user/judgeCenterLogin.jspx?disputesId=329";
		Connection connection = Jsoup.connect(url).userAgent("Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36");
		Document doc;
		try {
			doc = connection.get();
			logger.info(doc);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			logger.error(e.getMessage());
			e.printStackTrace();
		}
		
	}
	//调解
	@Test
	public void fayuanTest() {
		String url="http://www.fayuan.com/apply/joinApply?mediatorId=1280&disputeType=%E5%85%B6%E4%BB%96%E6%B0%91%E4%BA%8B%E7%BA%A0%E7%BA%B7&dispute=%E6%B3%95%E6%92%92%E6%97%A6%E6%B3%95%E6%92%92%E6%97%A6&claims=%E5%8F%91%E9%80%81%E5%88%B0%E5%8F%91%E9%80%81%E5%88%B0%E5%88%86&party1Name=%E6%9C%B1%E6%99%93%E7%AB%B9&party1Tel=15921013198";
		Connection connection = Jsoup.connect(url).userAgent("Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36");
		Document doc;
		try {
			doc = connection.get();
			String cssQuery=".class #id";
			Elements element = doc.select(cssQuery);
			logger.info(element);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			logger.error(e.getMessage());
			e.printStackTrace();
		}
		
	}
	@Test
	public void testJson(){
		SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		Log log=new Log();
		log.setModule("module");
		log.setRemark("no remark");
		log.setTime(sdf.format(new Date()));
		log.setRun(true);
		System.out.println(log.json());
	}

}
